import { _decorator, Component, Node, Canvas, sys, view } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('AdjustCanvas')
export class AdjustCanvas extends Component {


    canvas: Canvas;
    isFullScreen: boolean = false;

    onLoad() {
        (this.canvas = this.node.getComponent(Canvas)),
            sys.isMobile ? window.addEventListener("resize", this.onResized.bind(this)) : view.on("canvas-resize", this.onResized, this),
            this.updateFitMode();
    }

    onResized() {
        this.updateFitMode();
    }

    updateFitMode() {
        var e = view.getFrameSize(),
            r = e.width,
            n = e.height / r;

        if (this.isFullScreen && n < 16 / 9) {

        }
        // (this.isFullScreen = !1),
        //     n < 16 / 9
        //         ? ((this.canvas.fitHeight = !0), (this.canvas.fitWidth = !0))
        //         : ((this.canvas.fitHeight = !1), (this.canvas.fitWidth = !0), n >= Define.FULL_SCREEN_MIN_RATE && (this.isFullScreen = !0));
    }


    start() {

    }

    update(deltaTime: number) {

    }
}


